package jianshengaunli;

import net.sf.json.JSONArray;
import net.sf.json.JSONException;
import net.sf.json.JSONObject;

public class JsonUtils {
	public static void addToJsonArray(JSONArray jsonArray, Object... keyValues) throws JSONException {
       
		if (keyValues.length % 2 != 0) {
            throw new IllegalArgumentException("Invalid number of arguments. Arguments should be key-value pairs.");
        }

        JSONObject jsonObject = new JSONObject();
        for (int i = 0; i < keyValues.length; i += 2) {
            String key = (String) keyValues[i];
            Object value = keyValues[i + 1];
            jsonObject.put(key, value);
        }

        jsonArray.put(jsonObject);
    }
	
	

}
